import grpc
import common_pb2
import common_pb2_grpc
import os


def get_client():
    host = os.popen("docker inspect --format '{{ .NetworkSettings.IPAddress }}' " + "grpc-dev").read().strip()
    print(host)
    channel = grpc.insecure_channel(f"{host}:50051")
    stub = common_pb2_grpc.RpcServiceStub(channel)    
    return stub


cli = get_client()
req = common_pb2.Entity()
req.name = "this is test entity"
f1 = req.fields.add()
f1.name = 'command_type'
f1.iv.append(1)
f2 = req.fields.add()
f2.name = 'speedup'
f2.iv.append(3)
f3 = req.fields.add()
f3.name = 'step_time'
f3.iv.append(4)
entity = cli.RpcCall(req)
print(entity)
